













"ui";
login()
yz_qh = 914288609;
importClass(android.text.TextWatcher);
importClass(android.net.wifi.WifiManager);
importClass(java.lang.reflect.Method);
importClass(android.telephony.TelephonyManager);
importClass(android.widget.AdapterView.OnItemSelectedListener);
importClass(android.widget.Spinner);
importClass(android.graphics.drawable.GradientDrawable)
const scale = context.getResources().getDisplayMetrics().density;
global.dp2px = function(dp) {
    return Math.floor(dp * scale + 0.5);
};
global.px2dp = function(px) {
    return Math.floor(px / scale + 0.5);
};
var wg1 = parseInt((device.width - dp2px(8)) / 10);
var Q群;
var QQ = "52666830"
var ys = "#009688";
var QQ2 = "2261513571"
importClass("java.security.SecureRandom");
importClass("java.security.MessageDigest");
importClass("javax.crypto.spec.DESKeySpec");
importClass("javax.crypto.SecretKeyFactory");
importClass("javax.crypto.Cipher");
importClass("java.security.NoSuchAlgorithmException");
importClass("javax.crypto.KeyGenerator");
importClass("javax.crypto.SecretKey");
importClass("javax.crypto.spec.SecretKeySpec");
importClass("javax.crypto.KeyGenerator");
importClass("javax.crypto.spec.IvParameterSpec");
var srcarr = ["file://./res/bg4.png"];
importClass(android.graphics.drawable.GradientDrawable);
var gd = new GradientDrawable();
gd.setCornerRadius(20);
gd.setStroke(3, colors.parseColor('#AEEEEE'), 0, 0);
importClass(android.view.View);
function login() {
    importClass(android.graphics.drawable.GradientDrawable);
    var gd = new GradientDrawable();
    gd.setCornerRadius(20);
    gd.setStroke(3, colors.parseColor('#000000'), 0, 0);
    importClass(android.view.View);

    ui.layout(
        <vertical>
            <vertical id='login' w="*" gravity="center" >
                <text text="Q群验证请扫码登陆" textStyle='bold' gravity="center" />
                <relative w="*" gravity="center">
                    <horizontal gravity="center" w="*">
                        <img id='qrCode' w="200" h="200" />
                    </horizontal>
                    // <card id="er" w="*" h="300" margin="10 5" alpha="0.5"cardCornerRadius="2dp"  gravity="center_vertical">
                    <vertical h="200" w="*" gravity="center">
                        <horizontal id='bg' w="200" h="200" bg="#B2000000" gravity="center" >
                            <text id='msg' textStyle='bold' text="QQ扫码登陆" gravity="center" textColor="red" />
                        </horizontal>
                    </vertical>
                    //   </card>
                </relative>
            </vertical>
            
            <frame>
                
                
                
                
                
                <vertical>
                    
                    
                    
                    <card id="eeer" w="*" h="auto" margin="10 5" alpha="0.5"cardCornerRadius="2dp"  gravity="center_vertical">
                        <button text="Q群验证" id="qqyz"/>
                    </card>
                    
                    <card id="eeeer" w="*" h="auto" margin="10 5" alpha="0.5"cardCornerRadius="2dp"  gravity="center_vertical">
                        <button text="卡密验证" id="kmyz"/>
                    </card>
                    
                    
                    <text layout_gravity="center|bottom" w="auto" h="auto" text="Copyright@1999-2020鸿星.All Rights Reserved 鸿星科技 版权所有" textSize="10"/>
                    
                </vertical>
                
                
                
                
            </frame>
            
            
            
        </vertical>
    )
   // ui.eer.setBackground(gd)
    ui.eeer.setBackground(gd)
    ui.eeeer.setBackground(gd)
    ui.login.on("click", () => {
        getQrCode()
    });
    ui.bg.visibility = 8;
    getQrCode()




ui.qqyz.click(function() {
    var q = storage.get("bdqh")
    if (q == undefined || q == "") {
        toast("请登录")
    }
    
    if (q.indexOf(yz_qh) == -1) {
        toast("未在群内请加群")
    } else {
        toast("在群内")
        ui.run(() => {
           toast("通过验证，即将载入界面")
           zcj()
        })
    }



})
ui.kmyz.click(function() {
   ui.run(()=>{
   loginUI()
      });

})

var storage = storages.create("cookie");
var cookie = storage.get("cookie");
var bkn = storage.get("bkn");
var qqname = storage.get("name");
var qunjson;
var onscrollthreads;
var addstate = true;
var qqqunnum;
var qunjson;
var qqjson;
var qqlistnum = 0;





threads.start(function() {
    var data = http.get("https://qun.qq.com/cgi-bin/qun_mgr/get_group_list?bkn=" + bkn, {
        headers: {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36 Edg/83.0.478.58',
            'Cookie': cookie
        }
    })

    json = data.body.json();
    if (json.ec == 0) {

        ui.run(function() {
            toast("正在获取群列表")
            log(json.join)
            toast("获取群列表成功")
       
            var aaa = json.join
            var aaaa = JSON.stringify(aaa)
            var pw = aaaa.length;
            if (aaaa.indexOf(yz_qh) == -1) {
                toast("未在群内请加群或者进行卡密验证")
            } else {
                toast("查到缓存，请直接验证")
                storage.put("bdqh", JSON.stringify(aaaa))
                
            }


        })
    } else {

        toast("获取群列表失败，请登录/如有缓存请直接验证")
        login()
    }
})

var ptqrtoken = '';
var login_sig = '';
var heartbeatThreads;
var skey = '';


function getQrCode() {
    ui.bg.visibility = 8;
    try {
        heartbeatThreads.interrupt()
    } catch (e) {}
    threads.start(function() {
        var headers = http.get("https://xui.ptlogin2.qq.com/cgi-bin/xlogin?pt_disable_pwd=1&appid=715030901&daid=73&pt_no_auth=1&s_url=https%3A%2F%2Fqun.qq.com%2Fmanage.html").headers;
        cookie = '';

        if (headers['set-cookie']) {
            var name = "set-cookie";
        } else {
            var name = "Set-Cookie";
        }

        for (var a = 0; a < headers[name].length; a++) {
            var str = headers[name][a].split(';')[0]
            cookie += str + ';';
            if (str.indexOf("pt_login_sig=") != -1) {
                login_sig = str.split('pt_login_sig=')[1];
            }
        }
        var qrCode = http.get("https://ssl.ptlogin2.qq.com/ptqrshow?appid=715030901&e=2&l=M&s=3&d=72&v=4&t=0.123450544874" + random(10000, 99999) + "&daid=73&pt_3rd_aid=0", {
            headers: {
                'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36 Edg/83.0.478.58',
                'Cookie': cookie
            }
        });
        files.writeBytes("/sdcard/qrCode.png", qrCode.body.bytes());
        ui.run(function() {
            ui.qrCode.setSource('file:///sdcard/qrCode.png')
        })
        var str = qrCode.headers['Set-Cookie'];
        if (!str) {
            var str = qrCode.headers['set-cookie'];
        }
        var qrsig = str.split(';')[0]
        ptqrtoken = qrtoken(qrsig);
        cookie += qrsig + ';';
        heartbeatThreads = threads.start(function() {
            heartbeat()
        })
    })
}

//ptqrtoken 算法
function qrtoken(t) {
    t = t.split('qrsig=')[1];
    for (var e = 0, i = 0, n = t.length; i < n; ++i)
        e += (e << 5) + t.charCodeAt(i);
    return 2147483647 & e
}

//二维码状态心跳
function heartbeat() {
    while (true) {
        sleep(1000);
        var url = "https://ssl.ptlogin2.qq.com/ptqrlogin?u1=https%3A%2F%2Fqun.qq.com%2Fmanage.html&ptqrtoken=" +
            ptqrtoken +
            "&ptredirect=1&h=1&t=1&g=1&from_ui=1&ptlang=2052&action=0-0-" +
            new Date().getTime() +
            "&js_ver=20070110&js_type=1&login_sig=" +
            login_sig +
            "&pt_uistyle=40&aid=715030901&daid=73&";
        var state = http.get(url, {
            headers: {
                'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36 Edg/83.0.478.58',
                'Cookie': cookie
            }
        });
        var str = state.body.string()
        if (str.indexOf("ptuiCB") != -1) {
            eval(str)

        }
    }
}


//判断是否登录成功
function ptuiCB(state, bzd, url, login, msg, username) {
    if (login == 0) {
        if (state != 66) {

            ui.run(function() {
                ui.bg.visibility = 0;
                ui.msg.setText(msg);
            })
            if (state != 67) {
                heartbeatThreads.interrupt()
            }
        }
    } else if (login == 1) {
        ui.run(function() {
            ui.bg.visibility = 0;
            ui.msg.setText(msg);
        })
        // toastLog(msg)
        var okhttp = new Packages.okhttp3.OkHttpClient.Builder().followRedirects(false);
        http.__okhttp__.muteClient(okhttp);

        var data = http.get(url, {
            headers: {
                'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36 Edg/83.0.478.58',
                'Cookie': cookie
            }
        });

        if (data.headers['set-cookie']) {
            var name = "set-cookie";
        } else {
            var name = "Set-Cookie";
        }
        cookie = '';
        for (var a = 0; a < data.headers[name].length; a++) {
            var str = data.headers[name][a].split(';')[0]
            if (str != "pt4_token=" && str != "p_skey=" && str != "p_uin=") {
                cookie += str + ';';
            }
            if (str.indexOf("skey=") != -1 && str.indexOf("p_skey=") == -1) {
                skey = str.split('skey=')[1];
            }

        }


        storage.put("cookie", cookie);
        storage.put("bkn", databkn(skey));
        storage.put("name", username);
        bkn = databkn(skey);
        qqname = username;

        var data = http.get("https://qun.qq.com/cgi-bin/qun_mgr/get_group_list?bkn=" + bkn, {
            headers: {
                'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36 Edg/83.0.478.58',
                'Cookie': cookie
            }
        });
        qunjson = data.body.json();
        if (qunjson.ec == 0) {

            wwc = JSON.stringify(qunjson)
            toast("获取群列表成功")
            var qh = storages.create("yzbdqh")
            storage.put("bdqh", JSON.stringify(qunjson.join))
            toast("群号已保存到本地")

            //    qunlist.setAndNotify(wwc)
        } else {
            toast('列表获取失败，1s后返回重新登录')
            sleep(1000)

            ui.run(() => {
                login()
            })

        }

        heartbeatThreads.interrupt()
    }
}

//bkn 算法
function databkn(skey) {
    for (var e = skey, t = 5381, n = 0, o = e.length; n < o; ++n)
        t += (t << 5) + e.charAt(n).charCodeAt();
    return 2147483647 & t
}


function loginUI() {
    ui.layout(
        <frame bg="file://./res/bg4.png">
            <vertical w="auto" h="auto" layout_gravity="center" alpha="0.7">
                <horizontal w="auto" h="auto" layout_gravity="center">
                    <card w="auto" h="auto" marginRight="25" cardCornerRadius="300">
                        <img id="ja" src="https://s1.ax1x.com/2020/08/17/deVTOO.jpg" w="50" h="50" foreground="?selectableItemBackground" clickable="true" />
                    </card>
                    <card w="auto" h="auto" marginRight="25" cardCornerRadius="300">
                        <img id="hx" src="https://s1.ax1x.com/2020/08/17/denbvt.jpg" w="50" h="50" foreground="?selectableItemBackground" clickable="true" />
                    </card>
                    <card w="auto" h="auto"  cardCornerRadius="300">
                        <img id="hm" src="https://s1.ax1x.com/2020/08/17/denLKP.jpg" w="50" h="50" foreground="?selectableItemBackground" clickable="true" />
                    </card>
                </horizontal>
                <card foreground="?selectableItemBackground" w="300" h="320" margin="20 80"
                cardCornerRadius="12dp" cardElevation="5dp" layout_gravity="center">
                <vertical>
                    <appbar bg="#000000">
                        <toolbar id="toolbar" title="" >
                            <img src="@drawable/ic_fingerprint_black_48dp" layout_gravity="left" tint="#ffffff" />
                            <text text="鸿星网络集团" textColor="#ffffff" textSize="17sp" layout_gravity="center" />
                            <card w="auto" h="auto" marginRight="25" layout_gravity="right" cardCornerRadius="300">
                                <img id="head_1" src="https://s1.ax1x.com/2020/08/17/denbvt.jpg" w="50" h="50" foreground="?selectableItemBackground" clickable="true" />
                            </card>
                        </toolbar>
                        <tabs id="tabs" tabSelectedTextColor="#edff2e" tabIndicatorColor="#edff2e"
                        tabGravity="fill" tabMode="fixed" h="30" />
                    </appbar>
                    <viewpager id="viewpager">
                        <frame>
                            <vertical h="auto" padding="16" layout_gravity="top">
                                <horizontal>
                                    <img w="30" h="30" src="@drawable/ic_person_black_48dp" layout_gravity="center" />
                                    <card w="*" h="auto" margin="10 3 3 3" cardCornerRadius="5dp" cardElevation="3">
                                        <input id="dlzh" paddingLeft="5" hint="请输入您的账号" lines="1" bg="#ffffff" gravity="left" />
                                    </card>
                                </horizontal>
                                <horizontal marginTop="5">
                                    <img w="30" h="30" src="@drawable/ic_https_black_48dp" layout_gravity="center" />
                                    <card w="*" h="auto" margin="10 3 3 3" cardCornerRadius="5dp" cardElevation="3">
                                        <horizontal w="*" layout_gravity="left" >
                                            <input id="dlmm" h="*" w="*" paddingLeft="5" hint="请输入您的密码" inputType="textPassword" lines="1" bg="#ffffff" gravity="left" layout_weight="1.8"/>
                                        </horizontal>
                                        <horizontal w="auto" layout_gravity="right|center" margin="0 5 5 0" >
                                            
                                        </horizontal>
                                    </card>
                                </horizontal>
                                <frame marginBottom="20">
                                    <horizontal w="auto" layout_gravity="left" >
                                       <button w="auto"text="立即登录" id="ljdl" style="Widget.AppCompat.Button.Colored"/>
                                    </horizontal>
                                    <horizontal w="auto" layout_gravity="right" >
                                        <button w="auto"text="返回群验证" id="fhqyz" style="Widget.AppCompat.Button.Colored"/>
                                    </horizontal>
                                  
                                </frame>
                                  
                                      
                            </vertical>
                        
                        </frame>
                        <frame>
                            <vertical h="auto" padding="16" layout_gravity="top">
                                <horizontal>
                                    <img w="30" h="30" src="@drawable/ic_person_black_48dp" layout_gravity="center" />
                                    <card w="*" h="auto" margin="10 3 3 3" cardCornerRadius="5dp" cardElevation="3">
                                        <input id="czzh" paddingLeft="5" hint="请输入您要充值的账号" lines="1" bg="#ffffff" gravity="left" />
                                    </card>
                                </horizontal>
                                <horizontal marginTop="5">
                                    <img w="30" h="30" src="@drawable/ic_screen_lock_portrait_black_48dp" layout_gravity="center" />
                                    <card w="*" h="auto" margin="10 3 3 3" cardCornerRadius="5dp" cardElevation="3">
                                        <input id="czkm" paddingLeft="5" hint="请输入您的卡密" inputType="textPassword" lines="1" bg="#ffffff" gravity="left" />
                                    </card>
                                </horizontal>
                                 <button text="立即充值" id="ljcz" style="Widget.AppCompat.Button.Colored"/>
                                <frame marginBottom="16">
                                    
                                    <horizontal w="auto" layout_gravity="right" >
                                        <button id="gmkm" text="购买卡密" textColor="#04bbf1" style="Widget.AppCompat.Button.Borderless.Colored" />
                                    </horizontal>
                                </frame>
                            </vertical>
                        </frame>
                        <frame>
                            <vertical h="auto" padding="16" layout_gravity="top">
                                <horizontal>
                                    <img w="30" h="30"src="@drawable/ic_assignment_black_48dp"layout_gravity="center"/>
                                    <card w="*" h="auto" margin="10 3 3 3" cardCornerRadius="5dp" cardElevation="3">
                                        <input id="zczh1" paddingLeft="5" hint="请输入您要注册的账号" lines="1" bg="#ffffff" gravity="left" />
                                    </card>
                                    
                                </horizontal>
                                <horizontal>
                                    <img w="30" h="30"src="@drawable/ic_https_black_48dp"layout_gravity="center"/>
                                    
                                    <card w="*" h="auto" margin="10 3 3 3" cardCornerRadius="5dp" cardElevation="3">
                                        <input id="zcmm" paddingLeft="5" hint="请输入您要注册的密码" lines="1" bg="#ffffff" gravity="left" />
                                    </card>
                                </horizontal>
                                <horizontal>
                                    <img  w="30"h="30"src="@drawable/ic_markunread_black_48dp"layout_gravity="center"/>
                                    <card w="*" h="auto" margin="10 3 3 3" cardCornerRadius="5dp" cardElevation="3">
                                        <input id="zcyx" paddingLeft="5" hint="请输入您的邮箱" lines="1" bg="#ffffff" gravity="left" />
                                    </card>
                                </horizontal>
                                
                                <button text="立即注册" id="ljzc" style="Widget.AppCompat.Button.Colored"/>
                                
                            </vertical>
                        </frame>
                    </viewpager>
                </vertical>
            </card>
        </vertical>
        <card alpha="0.5" w="*" h="40" margin="9 40" cardCornerRadius="7dp" layout_gravity="right|bottom">;
            <text text="软件定制|安卓脚本|安卓注册机|js收徒|鸿星"textColor="blue" gravity="center"/>;
        </card>;
        </frame>
    )

/*
var storage = storages.create("2261513571@qq.com");
    var mrzh = storage.get("zh")
    var mrmm = storage.get("mm")
    if (mrzh == ""||mrzh==undefined) {
        toast("请输入账号密码")
    } else if (mrzh != "" || mrmm != "") {
        ui.dlzh.setText(mrzh)
        ui.dlmm.setText(mrmm)
    }
*/
//activity.setSupportActionBar(ui.toolbar);

ui.viewpager.setTitles(["登录", "充值", "注册"]);
ui.tabs.setupWithViewPager(ui.viewpager);

ui.ljdl.click(function() {
    var 用户名 = ui.dlzh.text();
    var 密码 = ui.dlmm.text();
    threads.start(function() {
        var temp = http.post("http://w.eydata.net/d6cc07946ee35fa0", {
            "UserName": 用户名,
            "UserPwd": 密码,
            "Version": "1.0",
            "Mac": device.getMacAddress(),
            "MacTwo": device.getAndroidId()
        }).body.string()
        if (temp.length == 32) {
            var c = http.post("http://w.eydata.net/7315e5f3fd28a620", {
                "UserName": 用户名,
            }).body.string()
            var a = c.match(/\d+/g)
            var ntime = a[0] + a[1] + a[2] + a[3] + a[4] + a[5]
            if (toTime() < ntime || IntTime() < ntime) {
                toast("登录成功到期时间为:" + c)
                
                 var storage = storages.create("2261513571@qq.com");
                    if (storage.get("zh") == "" || storage.get("zh") == undefined) {
                        storage.put("zh", 用户名);
                        storage.put("mm", 密码);
                        toastLog("登录成功账号保存成功")
                    }
                    
                ui.run(() => {
                 zcj()
                })
            } else {
                toast("已过期，请及时续费:到期时间为" + c)
            }
        } else {
            toast(test(temp))
        }
    })
})
ui.ljcz.click(function() {
    var 充值账号 = ui.czzh.text();
    var 充值卡密 = ui.czkm.text();
    ui.czkm.text();
    threads.start(function() {
        var c = http.post("http://w.eydata.net/9dd78b8089d1ab67", {
            "UserName": 充值账号,
            "CardPwd": 充值卡密
        }).body.string()
        toastLog(test(c))


    })
})
ui.fhqyz.click(function(){
    ui.run(()=>{
        login()
        });
    
    })
ui.ljzc.click(function() {
    var 注册账号 = ui.zczh1.text();
    var 注册密码 = ui.zcmm.text();
    var 注册邮箱 = ui.zcyx.text();
    threads.start(function() {
        var a = http.post("http://w.eydata.net/06250f070c5973bd", {
            "UserName": 注册账号,
            "UserPwd": 注册密码,
            "Email": 注册邮箱,
            "Mac": device.getAndroidId()
        }).body.string();
        toastLog(test(a))
    })
})
ui.hm.click(function() {
    var view = ui.inflate(
        <vertical >
                    <text textSize="10"text="胡某QQ:2195153700"/>
                    
                </vertical>, null, false);
    dialogs.build({
        customView: view,
        title: "胡某",
        positive: "添加好友",
        negative: "取消",
        wrapInScrollView: false,
        autoDismiss: false
    }).on("positive", (dialog) => {
        app.startActivity({
            action: "android.intent.action.VIEW",
            data: "mqqapi://card/show_pslcard?uin=421488253",
            packageName: "com.tencent.mobileqq",
        })
        dialog.dismiss();
    }).on("negative", (dialog) => {
        dialog.dismiss();
    }).show();
})
ui.hx.click(function() {
    var view = ui.inflate(
        <vertical >
                    <text textSize="10"text="鸿星QQ:2261513571/52666830"/>
                    
                </vertical>, null, false);
    dialogs.build({
        customView: view,
        title: "鸿星",
        positive: "添加好友",
        negative: "取消",
        wrapInScrollView: false,
        autoDismiss: false
    }).on("positive", (dialog) => {
        app.startActivity({
            action: "android.intent.action.VIEW",
            data: "mqqapi://card/show_pslcard?uin=2261513571",
            packageName: "com.tencent.mobileqq",
        })
        dialog.dismiss();
    }).on("negative", (dialog) => {
        dialog.dismiss();
    }).show();
})
ui.ja.click(function() {

    var view = ui.inflate(
        <vertical >
                    <text textSize="10"text="九安QQ:2903914013"/>
                    
                </vertical>, null, false);
    dialogs.build({
        customView: view,
        title: "九安",
        positive: "添加好友",
        negative: "取消",
        wrapInScrollView: false,
        autoDismiss: false
    }).on("positive", (dialog) => {
        app.startActivity({
            action: "android.intent.action.VIEW",
            data: "mqqapi://card/show_pslcard?uin=2903914013",
            packageName: "com.tencent.mobileqq",
        })
        dialog.dismiss();
    }).on("negative", (dialog) => {
        dialog.dismiss();
    }).show();
})


ui.gmkm.click(function() {

    app.openUrl("https://www.csfaka.com/links/32BD9F09")


})


}


}

function zcj() {
    ui.layout(
        <frame bg="#FFFFFF">
            
            <vertical>
                <linear orientation="horizontal" gravity="center">
                    <text w="auto" h="auto" text="鸿星：邀请注册" textSize="20" textStyle="normal|italic|bold"/>
                </linear>
                <card id="bk2" w="*" h="40" margin="1 1 1 1" gravity="center">
                    <appbar>
                        <tabs id="tabs"bg="#FFFFFF"/>
                    </appbar>
                </card>
                <viewpager id="viewpager">
                    <frame>
                        <vertical>
                            <card id="bk1" w="*" h="40" margin="1 1 1 1" gravity="center">
                                <linear orientation="horizontal">
                                    <spinner id="jmpt" entries="海豚|待定" w="auto" h="*" layout_weight="1"textColor="{{ys}}"/>
                                    <input w="90" h="*" hint="用户名" gravity="center"textSize="10sp"id="jmzh" layout_weight="1" lines="3"/>
                                    <input w="90" h="*" hint="密码" inputType="textPassword"gravity="center"id="jmmm" lines="3" layout_weight="1"textSize="10sp"/>
                                    <button id="jmdl" text="登录"w="auto" h="*" layout_weight="1"style="Widget.AppCompat.Button.Borderless"/>
                                    
                                </linear>
                            </card>
                            //接码
                            <card id="bk3" w="*" h="40" margin="1 1 1 1" gravity="center">
                                <linear orientation="horizontal">
                                    <spinner id="dmpt" entries="联众|待定" w="auto" h="*" layout_weight="1"textColor="{{ys}}"/>
                                    <input w="90" h="*" hint="用户名"gravity="center" textSize="10sp"id="dmzh" layout_weight="1" lines="3"/>
                                    <input w="90" h="*" hint="密码" inputType="textPassword"gravity="center"id="dmmm" lines="3" layout_weight="1"textSize="10sp"/>
                                    <button id="dmdl" text="登录"w="auto" h="*"layout_weight="1"style="Widget.AppCompat.Button.Borderless"/>
                                    
                                </linear>
                            </card>
                            //打码
                            
                            <card id="bk4" w="*" h="40" margin="1 1 1 1" gravity="center">
                                <linear orientation="horizontal">
                                    <spinner id="ipxz" entries="讯代理(优)|熊猫代理(优)" w="auto" h="*" layout_weight="1"textColor="{{ys}}"/>
                                    
                                    <input w="90" h="*" hint="Api链接(JSON)" gravity="center"id="IpApi" lines="3" layout_weight="1"textSize="10sp"/>
                                    <button id="IpCeShi" text="测试"w="auto" h="*"layout_weight="1"style="Widget.AppCompat.Button.Borderless"/>
                                    
                                </linear>
                            </card>
                            //IP
                            
                            
                            <card id="bk5" w="*" h="40" margin="1 1 1 1" gravity="center">
                                <linear orientation="horizontal">
                                    
                                    <input w="90" h="*" hint="邀请码" textSize="10sp" gravity="center"id="yqm" layout_weight="1" lines="3"/>
                                    <input w="90" h="*" hint="项目ID" id="xmid" lines="3"gravity="center" layout_weight="1"textSize="10sp"/>
                                    <input w="90" h="*" hint="邀请次数" id="yqcs" lines="3" gravity="center"layout_weight="1"textSize="10sp"/>
                                    
                                    <input w="90" h="*" hint="密码" textSize="10sp" gravity="center"id="mm" layout_weight="1" lines="3"/>
                                    <input w="90" h="*" hint="交易密码" id="jymm" lines="3"gravity="center" layout_weight="1"textSize="10sp"/>
                                </linear>
                            </card>
                            //基础填写
                            
                            <card id="bk6" w="*" h="40" margin="1 1 1 1" gravity="center">
                                <linear orientation="horizontal">
                                    <text text="料子区:"  textSize="15sp" layout_gravity="center" textStyle="bold"/>
                                    <button id="sfzz" text="正"w="auto" h="*"layout_weight="1"style="Widget.AppCompat.Button.Borderless"/>
                                    <button id="sfzf" text="反"w="auto" h="*"layout_weight="1"style="Widget.AppCompat.Button.Borderless"/>
                                    <button id="sfzsc" text="搜持"w="auto" h="*"layout_weight="1"style="Widget.AppCompat.Button.Borderless"/>
                                    <button id="wxskm" text="vvx收款码"w="auto" h="*"layout_weight="1"style="Widget.AppCompat.Button.Borderless"/>
                                    <button id="zfbskm" text="zfb收款码"w="auto" h="*"layout_weight="1"style="Widget.AppCompat.Button.Borderless"/>
                                    
                                </linear>
                            </card>
                            //料子
                            
                            <card id="bk9" w="*" h="40" margin="1 1 1 1" gravity="center">
                                <linear orientation="horizontal">
                                    <text text="料子区:"  textSize="15sp" layout_gravity="center" textStyle="bold"/>
                                    
                                    
                                    <checkbox id="dr" checked="flase" text="导入"/>
                                    
                                    
                                    <checkbox id="dq" checked="flase" text="读取右边"/>
                                    
                                    <input w="*" h="*" hint="格式:(姓名----sfz)" gravity="center"id="drlz" lines="3" layout_weight="1"textSize="10sp"/>
                                    
                                    
                                </linear>
                            </card>
                            
                            
                            <card id="bk7" w="*" h="40" margin="1 1 1 1" gravity="center">
                                <linear orientation="horizontal">
                                    
                                    <spinner id="yxxuanze" entries="邀请注册|日常养号" w="auto" h="*" layout_weight="1"textColor="{{ys}}"/>
                                    <button id="ksyx" text="开始运行" w="auto" h="*"gravity="center"layout_weight="1" style="Widget.AppCompat.Button.Borderless"/>
                                    <button id="jsyx" text="结束运行"w="auto" h="*"layout_weight="1" gravity="center"style="Widget.AppCompat.Button.Borderless"/>
                                    
                                </linear>
                            </card>
                            
                            
                            <card id="bk8" w="*" h="*" margin="1 1 1 1" gravity="center">
                                
                                
                                <vertical padding="1 1">
                                    <vertical padding="18 8" h="auto" gravity="center">
                                        <ScrollView>
                                            <text id="记录" text="运行日志：" layout_weight="1"textSize="11dp"/>
                                        </ScrollView>
                                    </vertical>
                                </vertical>
                                
                                
                            </card>
                            //日志输出
                            
                        </vertical>
                        
                    </frame>
                    
                    
                    
                    <frame>
                        
                        <card id="bk10" w="*" h="auto" margin="1 1 1 1" gravity="center">
                            <input w="*" h="*" hint="注意格式:姓名----sfz    一行一份可多行" gravity="center"id="drlz" lines="3" layout_weight="1"textSize="15sp"/>
                            
                        </card>
                    </frame>
                </viewpager>
                
            </vertical>
            
        </frame>

    )

    ui.viewpager.setTitles(["日常区", "导入区"]);
    ui.tabs.setTabTextColors(colors.parseColor("#1874CD"), colors.parseColor("#6495ED"));
    ui.tabs.setupWithViewPager(ui.viewpager);
    
    ui.bk1.setBackground(gd)
    ui.bk2.setBackground(gd)
    ui.bk3.setBackground(gd)
    ui.bk3.setBackground(gd)
    ui.bk4.setBackground(gd)
    ui.bk5.setBackground(gd)
    ui.bk6.setBackground(gd)
    ui.bk7.setBackground(gd)
    ui.bk8.setBackground(gd)
    ui.bk9.setBackground(gd);
    ui.bk10.setBackground(gd)

    function logStr(str) {
        var date = new Date();
        var s = "[" + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds() + "]";
        log(s + " " + str);
    }
    _log = log;
    var ara = [];
    var len = 80; //记录行数
    var limit = 6000;

    function log() {
        var s = '';
        for (var i = 0; i < arguments.length; i++) {
            s += '' + arguments[i] + ' ';
        }
        if ((ara.join("\n").length > limit ? true : false) || (ara.length > len ? true : false)) {
            ara.shift();
        }
        ara.push(s);
        var str = ara.join("\n");
        ui.run(() => {
            ui.记录.text(str);
        })
    }

    logStr("欢迎使用")
    logStr("有项目欢迎投稿QQ:52666830/2261513571")

    var images_sfzz;
    var images_sfzf;
    var images_sfzsc;
    var images_vxskm;
    var images_zfbskm;
    var jm_token;

    ui.sfzz.on("click", () => {
        startChooseFile("image/*", null, "sfzz");
    });
    ui.sfzf.on("click", () => {
        startChooseFile("image/*", null, "sfzf");
    });
    ui.sfzsc.on("click", () => {
        startChooseFile("image/*", null, "sfzsc");
    });
    ui.wxskm.on("click", () => {
        startChooseFile("image/*", null, "vxskm");
    })
    ui.zfbskm.on("click", () => {
        startChooseFile("image/*", null, "zfbskm");
    })

    ui.jmdl.on("click", () => {
        var 接码账号 = ui.jmzh.text();
        var 接码密码 = ui.jmmm.text();
        jmtoken = 海豚登录(接码账号, 接码密码)
        if (jmtoken == "登录失败") {
            logStr("登录失败")
        } else {
            logStr("登录成功! 余额为:" + 海豚金额(jmtoken))
            jm_token = jmtoken;
            ui.run(() => {
                ui.jmdl.setText(海豚金额(jmtoken))
            });

        };
    });
    ui.dmdl.on("click", () => {
        var 打码账号 = ui.dmzh.text();
        var 打码密码 = ui.dmmm.text();
        var 打码登录 = 联众登录(打码账号, 打码密码)
        if (打码登录 == "鸿星") {
            logStr("登录失败")
        } else {
            logStr(打码登录);
        }

    });
    ui.IpCeShi.on("click", () => {
        var url = ui.IpApi.text();
        threads.start(function() {
           xdl(url)
        })
    })
    ui.ksyx.on("click", () => {

    })






    function xdl(url) {
        var getIp_api = http.get('http://pv.sohu.com/cityjson?ie=utf-8').body.string();
        var str = getIp_api.replace("var returnCitySN = ", "")
        var str = str.replace(";", "")
        var json = JSON.parse(str)
        var 地址 = json.cip
        var 端口 = json.cid
        var 地区 = json.cname
        logStr("代理前IP：" + 地址 + "---" + 地区)
        var getProxy_json = http.get(url).body.json();
        var xdaili_proxyIP = getProxy_json.RESULT[0].ip;
        var xdaili_proxyPort = parseInt(getProxy_json.RESULT[0].port);
        httpProxy(xdaili_proxyIP, xdaili_proxyPort);
        var getIp_api1 = http.get('http://pv.sohu.com/cityjson?ie=utf-8').body.string();
        var str1 = getIp_api1.replace("var returnCitySN = ", "")
        var str2 = str1.replace(";", "")
        var json1 = JSON.parse(str2);
        var 地址1 = json1.cip
        var 地区1 = json1.cname
        logStr("代理后IP：" + 地址1 + "---" + 地区1)
     
    }


    function httpProxy(url, prot) {
        var Proxy = java.net.Proxy;
        var InetSocketAddress = java.net.InetSocketAddress;
        var okhttp = new Packages.okhttp3.OkHttpClient.Builder().proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(url, prot)));
        http.__okhttp__.muteClient(okhttp);
    };

    function isVpnUsed() {
        var niList = java.net.NetworkInterface.getNetworkInterfaces();
        if (niList != null) {
            var list = java.util.Collections.list(niList);
            for (var i = 0; i < list.size(); i++) {
                var Nane = list.get(i).getName();
                if ("tun0".equals(Nane) || "ppp0".equals(Nane)) return true;
            }
        }
        return false;
    }


    function 联众识别(打码账号, 打码密码, 图片地址) {

        var 图片码访问 = http.get(图片地址)
        //访问图片链接

        var cookie = 图片码访问.headers['Set-Cookie'];
        //取出图片吗的cookie
        log(cookie)

        var 编码为图片 = images.fromBytes(图片码访问.body.bytes())
        //把取出来的字节集数据(bytes)转换成图片数据(img)

        var 编码为base64 = images.toBase64(编码为图片)
        //把图片数据(img)转换成base64数据

        var base64编码内容 = 编码为base64; //变量转换

        var 识别接口 = "https://v2-api.jsdama.com/upload";

        var 识别图片 = http.postJson(识别接口, {
            softwareId: 13481,
            softwareSecret: "hSXU15ryxBNA3fD2ZaTE12sRX9Tu2Rr4TA78riwu",
            username: 打码账号,
            password: 打码密码,
            captchaData: base64编码内容,
            captchaType: 1001,
        }, {
            headers: {
                'Host': 'v2-api.jsdama.com',
                'Connection': 'keep-alive',
                'Content-Length': '298',
                'Accept': 'application/json, text/javascript, */*; q=0.01',
                'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12A365 MicroMessenger/5.4.1 NetType/WIFI',
                'Content-Type': 'text/json',
            }
        }).body.json();

        // log(识别图片);

        if (识别图片.code == 0) {
            var 图片码结果 = 识别图片.data.recognition;
            return 图片码结果
        } else {
            return "鸿星"
        }
    } ////联众识别函数尾


    function ua() {
        var a = http.get("https://fake-useragent.herokuapp.com/browsers/0.1.7").body.json();
        var ua = a.browsers.chrome[random(0, a.browsers.chrome.length)];
        return ua;
    } //随机ua函数
    function md5(string) {
        var res = java.math.BigInteger(1, java.security.MessageDigest.getInstance("MD5").digest(java.lang.String(string).getBytes())).toString(16);
        while (res.length < 32) res = "0" + res;
        return res;
    }



    function 联众登录(打码账号, 打码密码) {
        var 接口地址 = "https://v2-api.jsdama.com/check-points"
        var 检查点数 = http.postJson(接口地址, {
            softwareId: "13481",
            softwareSecret: "hSXU15ryxBNA3fD2ZaTE12sRX9Tu2Rr4TA78riwu",
            username: 打码账号,
            password: 打码密码
        }, {
            headers: {
                'Host': 'v2-api.jsdama.com',
                'Connection': 'keep-alive',
                'Content-Length': '298',
                'Accept': 'application/json, text/javascript, */*; q=0.01',
                'User-Agent': 'Mozilla/5.0 (Linux; Android 5.1.1; letv x501 Build/LMY47I) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/39.0.0.0 Mobile Safari/537.36',
                'Content-Type': 'text/json',
            }
        }).body.json()
        if (检查点数.code == 0) {
            var 联众账户 = "联众账号登陆成功！点数：" + 检查点数.data.availablePoints
            return 联众账户
        } else {
            return "鸿星"
        }
    } /////联众小尾巴
    function 海豚登录(账号, 密码) {
        var a = http.get("http://api.haitunpt.com/sms/?api=login&user=" + 账号 + "&pass=" + 密码).body.json();
        if (a.code == 0) {
            return a.token
        } else if (a.code != 0) {
            return "登录失败"
        }
    }

    function 海豚金额(token) {
        var a = http.get("http://api.haitunpt.com/sms/?api=getSummary&token=" + token).body.json();
        if (a.code == 0) {
            return a.money
        } else {
            return "登录失败"
        }
    }

    function 海豚获取手机(token, xmid) {
        var a = http.get("http://api.haitunpt.com/sms/?api=getPhone&token=" + token + "&sid=" + xmid + "&author=fjh226151&ascription=2").body.json();
        if (a.code == 0) {
            return a.phone
        } else {
            return "鸿星"
        }
    }

    function 海豚释放手机(token, xmid, phone) {
        var a = http.get("http://api.haitunpt.com/sms/?api=cancelRecv&token=" + token + "&sid=" + xmid + "&phone=" + phone).body.json();
        if (a.code == 0) {
            return "释放成功"
        } else {
            return "释放失败"
        }
    }

    function 海豚获取验证码(token, xmid, phone) {
        var a = http.get("http://api.haitunpt.com/sms/?api=getMessage&token=" + token + "&sid=" + xmid + "&phone=" + phone).body.json();
        if (a.code == 0) {
            return a.yzm
        } else {
            return "鸿星"
        }
    }


    function deletePorxy() {
        http.__okhttp__.muteClient(new Packages.okhttp3.OkHttpClient.Builder().proxy(java.net.Proxy.NO_PROXY));
    };

    var ResultIntent = {
        intentCallback: {},
        init: function() {
            activity.getEventEmitter().on("activity_result", (requestCode, resultCode, data) => {
                this.onActivityResult(requestCode, resultCode, data);
            });
        },
        startActivityForResult: function(intent, callback) {
            var i;
            for (i = 0; i < 65536; i++) {
                if (!(i in this.intentCallback)) break;
            }
            if (i >= 65536) {
                toast("启动Intent失败：同时请求的Intent过多");
                return;
            }
            this.intentCallback[i] = callback;
            activity.startActivityForResult(intent, i);
        },
        onActivityResult: function(requestCode, resultCode, data) {
            var cb = this.intentCallback[requestCode];
            if (!cb) return;
            delete this.intentCallback[requestCode];
            cb(resultCode, data);
        }
    };
    ResultIntent.init();

    function URIUtils_uriToFile(uri) { //Source : https://www.cnblogs.com/panhouye/archive/2017/04/23/6751710.html
        var r = null,
            cursor, column_index, selection = null,
            selectionArgs = null,
            isKitKat = android.os.Build.VERSION.SDK_INT >= 19,
            docs;
        if (uri.getScheme().equalsIgnoreCase("content")) {
            if (isKitKat && android.provider.DocumentsContract.isDocumentUri(activity, uri)) {
                if (String(uri.getAuthority()) == "com.android.externalstorage.documents") {
                    docs = String(android.provider.DocumentsContract.getDocumentId(uri)).split(":");
                    if (docs[0] == "primary") {
                        return android.os.Environment.getExternalStorageDirectory() + "/" + docs[1];
                    }
                } else if (String(uri.getAuthority()) == "com.android.providers.downloads.documents") {
                    uri = android.content.ContentUris.withAppendedId(
                        android.net.Uri.parse("content://downloads/public_downloads"),
                        parseInt(android.provider.DocumentsContract.getDocumentId(uri))
                    );
                } else if (String(uri.getAuthority()) == "com.android.providers.media.documents") {
                    docs = String(android.provider.DocumentsContract.getDocumentId(uri)).split(":");
                    if (docs[0] == "image") {
                        uri = android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
                    } else if (docs[0] == "video") {
                        uri = android.provider.MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
                    } else if (docs[0] == "audio") {
                        uri = android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
                    }
                    selection = "_id=?";
                    selectionArgs = [docs[1]];
                }
            }
            try {
                cursor = activity.getContentResolver().query(uri, ["_data"], selection, selectionArgs, null);
                if (cursor && cursor.moveToFirst()) {
                    r = String(cursor.getString(cursor.getColumnIndexOrThrow("_data")));
                }
            } catch (e) {
                log(e)
            }
            if (cursor) cursor.close();
            return r;
        } else if (uri.getScheme().equalsIgnoreCase("file")) {
            return String(uri.getPath());
        }
        return null;
    }

    function toba(path) {
        var img = images.read(path);
        img = images.toBase64(img);
        //toastLog(img);
        return img;
    };

    function startChooseFile(mimeType, callback, type) {
        var i = new android.content.Intent(android.content.Intent.ACTION_GET_CONTENT);
        i.setType(mimeType);
        ResultIntent.startActivityForResult(i, function(resultCode, data) {
            if (resultCode != activity.RESULT_OK) return;
            var f = URIUtils_uriToFile(data.getData());
            if (type == "sfzz") {
                images_sfzz = f;
                ui.run(() => {
                    logStr("已读取沈份正果辉面文件:" + f);
                });
            } else if (type == "sfzf") {
                images_sfzf = f;
                ui.run(() => {
                    logStr("已读取沈份正姓名面文件:" + f);
                });
            } else if (type == "sfzsc") {
                images_sfzsc = f;
                ui.run(() => {
                    logStr("已读取手持文件:" + f);
                });
            } else if (type == "vxskm") {
                images_vxskm = f;
                ui.run(() => {
                    logStr("已读取卫星收款码文件:" + f);
                });
            } else if (type == "zfbskm") {
                images_zfbskm = f;
                ui.run(() => {
                    logStr("已读取 只滏宝收款码文件:" + f)
                });
            };

        })


    }
}

function test(id) {
    var c = {
        "1": "操作成功",
        "-1": "网络链接失败",
        "-2": "请填写程序密钥,请联系开发者解决",
        "-3": "数据异常",
        "-4": "数据异常",
        "-5": "错误的参数,请检查参数是否正确",
        "-6": "还未登录",
        "-8": "账户余额不足",
        "-9": "注册用户达到上限",
        "-10": "非Vip无法使用此接口",
        "-11": "开启自动状态检测失败,还未登陆!",
        "-12": "开启自动状态检测失败!",
        "-14": "错误的调用",
        "-15": "频繁调用,请等待10分钟后再做尝试",
        "-16": "接口未开启",
        "-17": "错误的调用方式,请确认后台接口的调用方式",
        "-18": "服务器内部错误,请联系管理员解决",
        "-19": "接口调用失败,调用次数不足",
        "-20": "变量数据不存在",
        "-101": "用户名填写错误,必须以字母开头6-16位字母或数字!",
        "-102": "用户不存在",
        "-103": "请先登陆",
        "-104": "密码填写错误,请输入6-16位密码！",
        "-105": "邮箱填写错误,请正确输入邮箱,最大长度32！",
        "-106": "用户名重复",
        "-107": "邮箱重复!",
        "-108": "新密码输入错误",
        "-109": "用户名或密码错误",
        "-110": "用户使用时间已到期",
        "-111": "用户未在绑定的手机上登陆",
        "-112": "用户在别的地方登陆.主要原因是后台检测不到用户的状态码后台->用户管理->在线用户里面不存在这个状态码就会提示这个错误",
        "-13": "过期时间有误",
        "-114": "登录数据不存在",
        "-115": "用户已被禁用",
        "-116": "密码修改申请过于频繁",
        "-117": "未输入机器码",
        "-120": "注册失败,注册次数超过限制",
        "-122": "用户已经被删除",
        "-123": "用户密码输入错误",
        "-124": "用户登录数达到最大!",
        "-125": "错误的用户操作类别",
        "-127": "用户充值失败",
        "-129": "用户被开发者禁止使用,请咨询开发者是否被拉到黑名单",
        "-128": "用户数据超过最大限制",
        "-131": "用户使用次数不足",
        "-133": "用户状态码错误",
        "-134": "用户状态码不存在",
        "-206": "程序版本需要更新",
        "-208": "程序未开启后台接口功能.可在“程序”的“修改”界面开启后台接���功能",
        "-210": "程序停止新用户注册",
        "-301": "卡密输入错误",
        "-302": "卡密不存在",
        "-303": "卡密已经使用!",
        "-304": "卡密已经过期",
        "-305": "卡密已经冻结",
        "-306": "卡密已经退换",
        "-307": "接口未开启",
        "-308": "卡密已经换卡",
        "101": "充值成功!未填写推荐人",
        "102": "充值成功!填写推荐人获赠时间失败",
        "103": "充值成功!添加推荐信息失败",
        "104": "充值成功!推荐人获赠时间失败",
        "105": "充值成功!充值的卡密类别不支持推荐人功能",
        "106": "充值成功!充值的卡密类别推荐功能已关闭"
    };
    if (!c[id]) return "未知错误，状态码" + id;
    return c[id];
}


function  duibi(a, b) {     
    var  arr = a.split("-");     
    var  starttime =  new  Date(arr[0], arr[1], arr[2]);     
    var  到期日期 = starttime.getTime();     
    var  arrs = b.split("-");     
    var  endTime =  new  Date(arrs[0], arrs[1], arrs[2]);     
    var  现行日期 = endTime.getTime()
    if (现行日期 >= 到期日期) {
        return "欢迎使用"
    } else {
        return "您已到期，请及时续费"
    }
}

function toTime() {
    return new java.text.SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
}

function IntTime() {
    try {
        var recode_suning = http.get("http://quan.suning.com/getSysTime.do");
        var suningTime = recode_suning.body.json();
        return suningTime.sysTime1;
    } catch (e) {}
}

//跳转QQ号个人界面
function tzqq(QQ号) {
    app.startActivity({
        action: "android.intent.action.VIEW",
        data: "mqqapi://card/show_pslcard?&uin=" + QQ号
    });
}
//打开QQ咨询（不加好友聊天，需要目标QQ号开启QQ咨询）
function qqzx(QQ号){
    app.startActivity({
        action: "android.intent.action.VIEW",
    data: "mqqwpa://im/chat?chat_type=wpa&uin="+QQ号+"&version=1&src_type=web&web_src=oicqzone.com"
})
}
    //跳转QQ群
function tzqqq(群号){
app.startActivity({
    action: "android.intent.action.VIEW",
    data:"mqqapi://card/show_pslcard?src_type=internal&version=1&uin="+群号+"&card_type=group&source=qrcode"
});
}